<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./../Template.xhtml">

         

            <ui:define name="content">
                <h:form id="lei">
                    <p:growl id="lei_message"/>
                    <p:panel id="profLotacao" header="Cadastro de Professor no LEI">
                        
                    
                    <p:panel header="Lotação do Professor" id="tabGeral">
                    
                        
                        <h:panelGrid columns="2" id="pnlLotacao">
                        
                        <h:outputText value="Escola.:"/>
                        <p:selectOneMenu value="#{leiFaces.selectedEscola}" converter="EscolaConverter" required="true" label="Escola">
                             <f:selectItem itemLabel="Selecione" itemValue="#{null}"/>
                            <f:selectItems value="#{escolaFaces.allEscolas}" var="esc" itemLabel="#{esc.escola}" itemValue="#{esc}"/>
                            <p:ajax update="professor_list" listener="#{leiFaces.profPorEscola()}" immediate="false"/>
                        </p:selectOneMenu>
                        <h:outputText value="Professor.:"/>
                        <p:selectOneMenu value="#{leiFaces.selectedProfessor}" converter="ProfessorConverter" id="professor_list" required="true" label="Professor">
                             <f:selectItem itemLabel="Selecione" itemValue="#{null}"/>
                             <f:selectItems value="#{leiFaces.professores}" var="prof" itemLabel="#{prof.nome}" itemValue="#{prof}"  />
                        </p:selectOneMenu>
                        <h:outputText value="Número do LEI.:"/>
                        <p:inputText value="#{leiFaces.selectedLEi.num_lei}" required="true" label="Número do Lei" id="num_lei" size="2"  maxlength="2"   />
                        <h:outputText value="Quantidade de PCS.:"/>
                        <p:inputText value="#{leiFaces.selectedLEi.qtde_pc}" required="true" label="Quantidade de PC's" id="qtde_pc" size="3" maxlength="3"/>
                            </h:panelGrid>
                    </p:panel>
                    
                    <p:panel id="lotacao" header="Turnos e Carga Horária">
                        
                   
                        <h:panelGrid columns="2">
                            
                           
                            <h:outputText value="Manhã.:"/>
                            <p:selectBooleanCheckbox value="#{leiFaces.selectedTurno.manha}"/>
                             <h:outputText value="Tarde.:"/>
                            <p:selectBooleanCheckbox value="#{leiFaces.selectedTurno.tarde}"/>
                             <h:outputText value="Noite.:"/>
                            <p:selectBooleanCheckbox value="#{leiFaces.selectedTurno.noite}"/>
                             <h:outputText value="Integral.:"/>
                             <p:selectBooleanCheckbox value="#{leiFaces.selectedTurno.integral}"/>
                             <h:outputText value="C.H Total.:"/>
                             <p:inputText value="#{leiFaces.selectedTurno.chtotal}"  size="2" maxlength="2" required="true" label="Carga Horária"/>
                        </h:panelGrid> 
                    </p:panel>
                    <br/>
                    <p:messages id="mensagens"/>
                    <br/>
                     <p:commandButton value="Novo" update="lei:profLotacao" process="@this" actionListener="#{leiFaces.reset()}" />
                     <p:commandButton value="Gravar" action="#{leiFaces.add()}" update="ListaLei,lei_message,mensagens" />
                    <br/>
                    <br/>
                    
                    <p:dataTable var="lei" value="#{leiFaces.allLeis}" id="ListaLei" editable="true" style="text-align: center">
                        <f:facet name="header">
                            Lista de Leis e Lotação de Professores
                        </f:facet>

                       

                        <p:column headerText="Escola" style="width:30%">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <h:outputText value="#{lei.escola.escola}" />
                                </f:facet>
                                <f:facet name="input">
                                    <h:selectOneMenu value="#{leiFaces.selectedLEi.escola}" converter="EscolaConverter" >
                                        <f:selectItems value="#{escolaFaces.allEscolas}" 
                                                       var="esc" 
                                                       itemLabel="#{esc.escola}"
                                                       itemValue="#{esc}" />
                                    </h:selectOneMenu>
                                </f:facet>
                            </p:cellEditor>
                        </p:column>

                        <p:column headerText="Nº do LEI" style="width:20%">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <h:outputText value="#{lei.num_lei}" />
                                </f:facet>
                                <f:facet name="input">
                                    <p:inputText value="#{lei.num_lei}" style="width:100%" label="Número do lei"/>
                                </f:facet>
                            </p:cellEditor>
                        </p:column>

                        <p:column headerText="Qtde. de PC's" style="width:24%">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <h:outputText value="#{lei.qtde_pc}" />
                                </f:facet>
                                <f:facet name="input">
                                    <p:inputText value="#{lei.qtde_pc}" style="width:100%" label="Qtde. de PC's"/>
                                </f:facet>
                            </p:cellEditor>
                        </p:column>
                        <p:column headerText="Professor" style="width:24%">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <h:outputText value="#{lei.prof.nome}" />
                                </f:facet>
                                <f:facet name="input">
                                    <p:inputText value="#{lei.prof.nome}" style="width:100%" label="Professor"/>
                                </f:facet>
                            </p:cellEditor>
                        </p:column>
                         <p:column headerText="Turno Manhã" style="width:24%">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <h:outputText value="#{lei.turno.manha}" />
                                </f:facet>
                                <f:facet name="input">
                                    <p:selectBooleanCheckbox value="#{lei.turno.manha}"/>
                                </f:facet>
                            </p:cellEditor>
                        </p:column>
                        <p:column headerText="Turno Tarde" style="width:24%">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <h:outputText value="#{lei.turno.tarde}" />
                                </f:facet>
                                <f:facet name="input">
                                    <p:selectBooleanCheckbox value="#{lei.turno.tarde}" />
                                </f:facet>
                            </p:cellEditor>
                        </p:column>
                        <p:column headerText="Turno Noite" style="width:24%">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <h:outputText value="#{lei.turno.noite}" />
                                </f:facet>
                                <f:facet name="input">
                                    <p:selectBooleanCheckbox value="#{lei.turno.noite}"/>
                                </f:facet>
                            </p:cellEditor>
                        </p:column>
                          <p:column headerText="Turno Integral" style="width:24%">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <h:outputText value="#{lei.turno.integral}" />
                                </f:facet>
                                <f:facet name="input">
                                   <p:selectBooleanCheckbox value="#{lei.turno.integral}"/>
                                </f:facet>
                            </p:cellEditor>
                        </p:column>
                        <p:column headerText="C.H" style="width:24%">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <h:outputText value="#{lei.turno.chtotal}" />
                                </f:facet>
                                <f:facet name="input">
                                   <p:inputText value="#{lei.turno.chtotal}" style="width:100%" label="C.H"/>
                                </f:facet>
                            </p:cellEditor>
                        </p:column>




                        
                        <p:column style="width: 6%">
                            <f:facet name="header">
                                Apagar
                            </f:facet>
                            <p:commandButton   action="#{leiFaces.del()}"  ajax="false" update="lei:ListaLei" icon="ui-icon-trash" alt="Apagar Informações" label="Apagar" immediate="true">
                                <f:setPropertyActionListener target="#{leiFaces.selectedLEi}" value="#{lei}"/>
                            </p:commandButton>
                        </p:column>
                    </p:dataTable>
                    </p:panel>
                </h:form>
                     
            </ui:define>

            

        </ui:composition>

    </body>
</html>
